<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // function getMax(array) {
    //   let max = array[0]
    //   for(const i in array) {
    //     if (max < array[i]) {
    //       max = array[i]
    //     }
    //   }
    //   return max
    // }

    function getMax(array) {
      // return Math.max(...array)
      return Math.max.apply(null, array)
    }

    const arr = [3, 7, 1, 9, 2, 4, 5]
    const max = getMax(arr)

    console.log('max = ', max)
  </script>
</body>
</html>